package com;

import lombok.Data;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Hashtable;

/**
 * @className: Test
 * @description: TODO 类描述
 * @author: YUANG
 * @date: 2022/2/16
 **/
public class Test {
    public static void main(String[] args) {
//        int[] arr = {1, 2, 3, 4, 5};
//        int rank = rank(arr, 3);
//        System.out.println(rank);
        Person person = new Person("张三", 1);
        System.out.println(person.age);
        addAge(person);
        System.out.println(person.age);
    }

    public static class Person {
        String name;
        Integer age;

        public Person(String name, Integer age) {
            this.name = name;
            this.age = age;
        }


    }


    public static void addAge (Person p) {
        p.age++;
    }

    public static void sort(int[] arr) {
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static int rank(int[] arr, int a) {
        int n = arr.length;
        int lo = 0;
        int hi = n - 1;

        while (lo <= hi) {
            int mid = lo + (hi - lo) / 2;
            if (arr[mid] > a) {
                hi = mid - 1;
            } else if (arr[mid] < a) {
                lo = mid + 1;
            } else {
                return arr[mid];
            }
        }
        return -1;
    }
}
